package 工厂方法;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;


public abstract class OrderPizza {
	// 定义一个抽象方法
	abstract Pizza createPizza(String orderType);

	public OrderPizza() {
		Pizza pizza = null;
		String orderType; // 订购披萨的类型
		
		do {
			orderType = getType();
			pizza = createPizza(orderType);
			
			if(pizza != null) {
				pizza.prepare();
				pizza.bake();
			} else {
				System.out.println("订购失败");
				break;
			}
			
		} while(true);
	}
	
	private String getType() {
		try {
			BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
			System.out.println("input pizza 种类：");
			String str = strin.readLine();
			return str;
			
		} catch (IOException e) {
			// TODO: handle exception
			e.printStackTrace();
			return "";
		}
	}

}
